package com.lz.football.module.ladderMatch
{
	import com.common.stdlib.ArrayUtil;
	import com.common.stdlib.DateUtil;
	import com.common.utils.Reflection;
	import com.common.utils.timeUtils.TimerManager;
	import com.global.GlobalDef;
	import com.liangzhong.constants.ResourceConst;
	import com.liangzhong.events.AppEventDispatcher;
	import com.liangzhong.events.FriendEvent;
	import com.liangzhong.events.LadderEvent;
	import com.liangzhong.events.MainEvent;
	import com.liangzhong.events.ModuleEvent;
	import com.liangzhong.manager.ResourceManager;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.friend.vo.FriendInfoVo;
	import com.liangzhong.model.ladderMatch.vo.MatchTimeVo;
	import com.lz.football.module.ladderMatch.exchange.ExchangePanel;
	import com.lz.football.module.ladderMatch.item.LadderApplyItem;
	import com.lz.football.module.ladderMatch.item.LadderRankItem;
	import com.lz.football.module.ladderMatch.item.MatchResultItem;
	
	import common.BaseView.BaseView;
	import common.BaseView.DisplayMouseEventManager;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.filters.ColorMatrixFilter;
	import flash.text.TextField;
	
	import lz.controls.Alert;
	import lz.controls.nick.PagePanel;
	
	/**
	 * 天梯赛  
	 * @author Administrator
	 * 
	 */	
	public class LadderMatchView extends BaseView implements ILadderMatchView
	{
		
		/**
		 *报名容器 
		 */
		private var applyContain:MovieClip;
		/**
		 *排名容器 
		 */
		private var listContain:MovieClip;
		/**
		 * 
		 */
		private var _page:PagePanel;
		/**
		 *名称  
		 */
		private var playerName:TextField;
		//		/**
		//		 *等级加综合实力
		//		 */
		//		private var Lv:TextField;
		/**
		 *属性 
		 */
		private var propert:TextField;
//		/**
//		 * 队徽容器 
//		 */
//		private var iconContain:MovieClip;
//		/**
//		 *冠军 
//		 */
//		private var champion:TextField;
//		/**
//		 *亚军 
//		 */
//		private var runnerup:TextField;
//		
//		/**
//		 *季军 
//		 */
//		private var thirdWin:TextField;
//		/**
//		 *操作 
//		 */
//		private var _operationMc:LadderoperationView;
		
		/**
		 *取消比赛 
		 */
		private var cancelBtn:SimpleButton;
		/**
		 *报名比赛 
		 */
		private var applyBtn:SimpleButton;
		
		/**
		 *比赛时间 
		 */
		private var time:TextField;
		
		/**
		 *前十排名item 
		 */
		private var _topListItem:Vector.<LadderRankItem>;
		/**
		 *报名 
		 */
		private var _applyListItem:Vector.<LadderApplyItem>;
		/**
		 *天梯比赛周期时间 
		 */
		private var seasonTime:TextField;
		
		/**
		 *兑换按钮 
		 */
		private var exchangeBtn:SimpleButton;
		/**
		 *规则 
		 */
		private var ruleBtn:SimpleButton;
		/**
		 *更多排名  
		 */
		private var moreBtn:SimpleButton;
		/**
		 *阵容 设置 
		 */
		private var battleBtn:SimpleButton;
		
		/**
		 *排名列表 
		 */
		private var _rankingview:RankingPanel;
		/**
		 *兑换面板 
		 */
		private var _exchangeview:ExchangePanel;
		/**
		 *当前报名人数 
		 */
		private var applyNum:TextField;
//		/**
//		 *增加挑战次数 
//		 */
//		private var addFeelBtn:SimpleButton;
		/**
		 *更新报名列表
		 * 30秒一次 
		 */
		private var _updataApplyTime:int;
		
		/**
		 * 
		 */
		private var ladderlevel:TextField;
		/**
		 *排名  
		 */
		private var ladderrank:TextField;
		/**
		 *积分 
		 */
		private var integral:TextField;
		/**
		 *荣誉 
		 */
		private var honor:TextField;
		/**
		 * 
		 */
		private var _time:int;
		/**
		 *是否可以天梯比赛 
		 */
		private var _isSureMatch:Boolean;
		/**
		 *时间说明  
		 */
		private var timeDec:TextField;
		/**
		 *能力 
		 */
		private var ability:MovieClip;
		/**
		 *比赛结果容器 
		 */
		private var resultContain:MovieClip;
		/**
		 *比赛结果mc 
		 */
		private var resulctVec:Vector.<MatchResultItem>;
		
		/**
		 *挑战次数 
		 */
		private var challangeTime:TextField;
		/**
		 *增加挑战次数按钮 
		 */
		private var addBtn:SimpleButton;
		/**
		 *规则面板 
		 */
		private var _ruleView:RulePanel;
		public function LadderMatchView()
		{
			super();
		}
		override public function initUI(view:Object=null):void
		{
			symbolSkin = Reflection.createInstance("com.lz.modul.ladderMatch.mainview");
			this.addChild(symbolSkin);
			_windowBg = symbolSkin.ladderBg;
			isDrag = true;
			isCloseBtn = true;
			moveClose( symbolSkin.width - 30,25);
			_viewHeight = symbolSkin.height;
			_viewWidth = symbolSkin.width;
			onResizeHandler();
			applyContain = symbolSkin.applyMc.applyContain;
			listContain = symbolSkin.listContain;
			moreBtn = symbolSkin.moreBtn;
			playerName = symbolSkin.infoMc.playerName;
			timeDec = symbolSkin.timeDec;
			ability = symbolSkin.infoMc.ability;
			resultContain = symbolSkin.infoMc.resultContain;
			challangeTime = symbolSkin.infoMc.challangeTime;
			addBtn = symbolSkin.infoMc.addBtn;
			battleBtn = symbolSkin.battleBtn;
			seasonTime = symbolSkin.seasonTime;
			exchangeBtn = symbolSkin.exchangeBtn;
			ruleBtn = symbolSkin.ruleBtn;
			applyNum = symbolSkin.applyMc.applyNum;
			applyNum.text = "";
			ladderlevel = symbolSkin.infoMc.ladderlevel;
			ladderrank = symbolSkin.infoMc.ladderrank
			integral = symbolSkin.infoMc.integral
			honor = symbolSkin.infoMc.honor;
			
			time = symbolSkin.time;
			cancelBtn = symbolSkin.cancelBtn;
			applyBtn = symbolSkin.applyBtn;
			cancelBtn.visible = false;
			initApplyItem();
			initRankItem();
			initPage();
			initResultMc();
			showInfo();
			topList();
			addEvtListener();
		}
		/**
		 *更新报名列表 
		 * 
		 */
		private function prepareupdataApplyList():void
		{
			_updataApplyTime ++;
			if(_updataApplyTime >= 30)
			{
				this.dispatchEvent(new LadderEvent(LadderEvent.APPLY_LIST,{page:_page.min}));
				_updataApplyTime = 0;
			}
			
		}
		/**
		 *初始化报名item 
		 * 
		 */
		private function initApplyItem():void
		{
			_applyListItem = new Vector.<LadderApplyItem>();
			var item:LadderApplyItem;
			for(var i:int = 0;i < 6;i++)
			{
				item = new LadderApplyItem();
				item.initUI("com.lz.modul.ladderMatch.applyA");
				item.x = 0;
				item.y = i *(item.height + 2); 
				_applyListItem.push(item);
//				applyContain.addChild(item);
			}
		}
		/**
		 *初始化排名容器 
		 * 
		 */
		private function initRankItem():void
		{
			_topListItem = new Vector.<LadderRankItem>();
			var item:LadderRankItem;
			for(var i:int = 0;i < 12;i++)
			{
				item = new LadderRankItem();
				item.initUI();
				item.y = (item.height + 2) * int(i /3);
				item.x = (item.width + 3) * (i % 3);
				listContain.addChild(item);
				item.textColor = 4;
				_topListItem.push(item);
			}
			
			_topListItem[0].textColor = 1
			_topListItem[1].textColor = 2;
			_topListItem[2].textColor = 3;
			
		}
		
		private function initPage():void
		{
			_page = new PagePanel();
			_page.initUI("com.lz.commonUI.turnPage_white");
			_page.callBack = turnPage;
			symbolSkin.applyMc.page.addChild(_page);
		}
		/**
		 *初始化比赛结果  
		 * 
		 */		
		private function initResultMc():void
		{
			resulctVec = new Vector.<MatchResultItem>();
			var mc:MatchResultItem;
			for(var i:int = 0;i < 10;i++)
			{
				mc = new MatchResultItem();
				mc.initUI();
				resulctVec.push(mc);
				mc.y = int(i / 5) * mc.height;
				mc.x = (i % 5) * (mc.width + 2);
				resultContain.addChild(mc);
			}
		}
		/**
		 *换页  
		 * @param $type
		 * 
		 */
		private function turnPage($type:String = ""):void
		{
			this.dispatchEvent(new LadderEvent(LadderEvent.APPLY_LIST,{page:_page.min}));
		}
		
		/**
		 *显示基本信息 
		 * 
		 */
		private function showInfo():void
		{
			playerName.text = AppData.getInstance().clubDatamanager.clubInfo.uname + "";
			addFightTime(null);
			time.text = "00:00";
			timeDec.text =  "下轮开赛倒计时：";
			ability.gotoAndStop(1);
			var i:int = AppData.getInstance().clubDatamanager.clubInfo.ability;
			DisplayMouseEventManager.instance.addTipsDisplay(ability,"俱乐部综合能力：" + i);
			i = Math.ceil(i /20);
			ability.gotoAndStop(i);
			var xml:XML = ResourceManager.instance.getResource(ResourceConst.LADDERMATCHTIME);
//			seasonTime.text = xml.seasonTime;
//			DateUtil.getnatureWeek(AppData.getInstance().curDate);
			
			seasonTime.text = "本界天梯时间：" + DateUtil.getnatureWeek(AppData.getInstance().curDate);
			setResultData();
			checkTimeIsSureMatch();
			if(_isSureMatch)
				calculateTime();
			setHideBtn()
			if(AppData.getInstance().ladderDataManger.ladderInfovo.isApplyStatus)
			{
				cancelBtn.visible = true;
			}else
			{
				applyBtn.visible = true;
			}
		}
		private function levelChange():String
		{
			switch(AppData.getInstance().ladderDataManger.ladderInfovo.ladderlevel)
			{
				case 1:
					return "D";
				case 2:
					return "C";
				case 3:
					return "B";
				case 4:
					return "A";
				case 5:
					return "S";
			}
			return "D";
		}
		override public function addEvtListener():void
		{
			exchangeBtn.addEventListener(MouseEvent.CLICK,onexchangeHandler);
			ruleBtn.addEventListener(MouseEvent.CLICK,onruleHandler);
			moreBtn.addEventListener(MouseEvent.CLICK,onMoreHandler);
//			addFeelBtn.addEventListener(MouseEvent.CLICK,onAddFeelHandler);
			cancelBtn.addEventListener(MouseEvent.CLICK,onCancelHandler);
			
			applyBtn.addEventListener(MouseEvent.CLICK,onapplyHandler);
			battleBtn.addEventListener(MouseEvent.CLICK,onBattleHandler);
			TimerManager.instance.addFunction(prepareupdataApplyList);
			addBtn.addEventListener(MouseEvent.CLICK,onAddFeelHandler);
		}
		/**
		 *打开阵容设置 
		 * @param event
		 * 
		 */		
		protected function onBattleHandler(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			AppEventDispatcher.getInstance().dispatchEvent(new MainEvent(MainEvent.OPEN_PLAYERCENTER,{type:2}));
		}
		/**
		 *取消比赛  
		 * @param event
		 * 
		 */		
		protected function onCancelHandler(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			this.dispatchEvent(new LadderEvent(LadderEvent.APPLY_MATCH,{type:4},true));
		}
		/**
		 *报名比赛 
		 * @param event
		 * 
		 */
		protected function onapplyHandler(event:MouseEvent):void
		{
			if(AppData.getInstance().ladderDataManger.ladderInfovo.laddercount <= 0)
			{
				Alert.showErrorTip("今天的挑战次数已完成，请明天再来");
				return;
			}
			checkTimeIsSureMatch();
			if(!_isSureMatch)
			{
				Alert.showErrorTip("天梯赛开放时间为10-14点和19-23点！");
				return;
			}
			if(AppData.getInstance().playerCenterDataManager.fieldPlayerinjuredNum)
			{
				Alert.show("您的上场球员已经有5名受伤，球员们联合起来罢赛了！" +
					"他们抗议如此赤果果的压榨行为并且上报国际足联，老板，赶快去给他们疗伤吧~",
					"",Alert.NO,GlobalDef.AlertContainer,openPlayerCenter);
				return;
			}
			if(AppData.getInstance().playerCenterDataManager.fieldisinjured)
			{
				Alert.show("您当前的队伍中有球员受伤，会大大影响球队的实力！\n您可以在球员中心治疗受伤的球员！","",Alert.NO,GlobalDef.AlertContainer,sureMatch);
			}else
			{
				sureMatch(Alert.YES);
			}
			
		}
		
		private function openPlayerCenter(type:int):void
		{
			if(type == Alert.YES)
			{
				AppEventDispatcher.getInstance().dispatchEvent(new MainEvent(MainEvent.OPEN_PLAYERCENTER));
			}
		}
		
		
		/**
		 *确认比赛 
		 * 
		 */
		private function sureMatch(type:int):void
		{
			if(type == Alert.YES)
			{
				this.dispatchEvent(new LadderEvent(LadderEvent.APPLY_MATCH,{type:3,ballt:1},true));
			}
		}
		
		/**
		 *增加挑战次数 
		 * @param event
		 * 
		 */
		protected function onAddFeelHandler(event:MouseEvent):void
		{
			if(AppData.getInstance().ladderDataManger.ladderInfovo.laddercount >= 90)
			{
				Alert.showErrorTip("当前可挑战次数超过最大上限，不可增加！");
				return;
			}
			
			if(AppData.getInstance().clubDatamanager.clubInfo.cashpoint < 200)
			{
				Alert.noCashAlert("消耗200点卷可增加10次挑战次数。现有点券不足，是否前往充值?");
				return;
			}
			
			Alert.show("你确定消耗200点券购买10次挑战次数吗？","",Alert.NO,GlobalDef.AlertContainer,addFeelAlert);
			
		}
		/**
		 *是否增加挑战次数 
		 * @param $type
		 * 
		 */
		private function addFeelAlert($type:int):void
		{
			if($type == Alert.YES)
				this.dispatchEvent(new LadderEvent(LadderEvent.ADD_FIGHT_TIME));
		}
		/**
		 *更多排名  
		 * @param event
		 * 
		 */		
		protected function onMoreHandler(event:MouseEvent):void
		{
			if(_rankingview == null)
			{
				_rankingview = new RankingPanel();
				_rankingview.initUI();
			}
			if(AppData.getInstance().ladderDataManger.getLadderRankByType("S") == null || 
				AppData.getInstance().time - AppData.getInstance().ladderDataManger.updataMoreRankTime>=1800)//是否为30分钟
			{
				this.dispatchEvent(new LadderEvent(LadderEvent.MORE_LADDER_RANK));
			}else
			{
				_rankingview.show();
			}
			
			
			
			GlobalDef.GameWindowContainer.addChild(_rankingview);
			
		}
		/**
		 * 规则 
		 * @param event
		 * 
		 */		
		protected function onruleHandler(event:Event):void
		{
			// TODO Auto-generated method stub
			if(_ruleView == null)
			{
				_ruleView = new RulePanel();
				_ruleView.initUI();
			}
			GlobalDef.GameWindowContainer.addChild(_ruleView);
			
		}
		/**
		 *兑换 
		 * @param event
		 * 
		 */		
		protected function onexchangeHandler(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			if(_exchangeview == null)
			{
				_exchangeview = new ExchangePanel();
				_exchangeview.initUI();
				
			}
			_exchangeview.show(AppData.getInstance().ladderDataManger.ladderInfovo.ladderintegral,AppData.getInstance().ladderDataManger.ladderInfovo.honour);
			GlobalDef.GameWindowContainer.addChild(_exchangeview);
		}
		/**
		 *查看信息 
		 * @param event
		 * 
		 */		
		protected function onLinkHandler(event:TextEvent):void
		{
			var f:FriendInfoVo = new FriendInfoVo();
			f.friendid = int(event.text);
			AppEventDispatcher.getInstance().dispatchEvent(new FriendEvent(FriendEvent.LOOK_UP_FRIEND,{vo:f}));
		}

		
		/**
		 *前十名 
		 * 
		 */
		public function topList():void
		{
			if(AppData.getInstance().ladderDataManger.topList == null)return;
			while(listContain.numChildren)
				listContain.removeChildAt(0);
			var arr:Array = AppData.getInstance().ladderDataManger.topList;
			var len:int = arr.length;
			len = len > 12?12:len;
			for(var i:int = 0;i < len;i++)
			{
				_topListItem[i].data = arr[i];
				listContain.addChild(_topListItem[i]);
			}
		}
		/**
		 *更新报名列表 
		 * 
		 */
		public function updataApplyList($obj:Object):void
		{
			_updataApplyTime = 0;
			while(applyContain.numChildren)
			{
				applyContain.removeChildAt(0);
			}
			var arr:Array = $obj.arr//AppData.getInstance().ladderDataManger.applyList;
			_page.max = Math.ceil($obj.total /6);
			applyNum.text = "当前报名：" + $obj.total;
			if(_page.max < _page.min)
			{
				_page.min = _page.max;
			}
			var len:int = arr.length > 6?6:arr.length;
			for(var i:int = 0;i < len;i++)
			{
				_applyListItem[i].data = arr[i];
				applyContain.addChild(_applyListItem[i]);
			}
		}
		/**
		 *更新报名item 
		 * 
		 */
		private function updataShowApplyItem():void
		{
			_updataApplyTime = 0;
			if(AppData.getInstance().ladderDataManger.applyList == null)return;
			while(applyContain.numChildren)
			{
				applyContain.removeChildAt(0);
			}
			var arr:Array = ArrayUtil.getPageSizeDatas(_page.min , 5,AppData.getInstance().ladderDataManger.applyList);
			var len:int = arr.length > 5?5:arr.length;
			for(var i:int = 0;i < len;i++)
			{
				_applyListItem[i].data = arr[i];
				applyContain.addChild(_applyListItem[i]);
			}
		}
		/**
		 *增加挑战次数 
		 * @param $obj
		 * 
		 */
		public function addFightTime($obj:Object):void
		{
			ladderlevel.text = levelChange();
			ladderrank.text = AppData.getInstance().ladderDataManger.ladderInfovo.ladderrank + "";
			
			integral.text = AppData.getInstance().ladderDataManger.ladderInfovo.ladderintegral + "";
			honor.text = AppData.getInstance().ladderDataManger.ladderInfovo.honour + "";
			challangeTime.text = "当天可挑战次数："+AppData.getInstance().ladderDataManger.ladderInfovo.laddercount + "";

		}
		/**
		 *更多的排名  
		 * 
		 */
		public function moreRank():void
		{
			if(_rankingview != null)
			{
				_rankingview.show();
			}
		}
		/**
		 *天梯比赛状态 
		 * 
		 * 
		 */
		public function ladderMatchStatus($obj:Object):void
		{
//			_operationMc.ladderMatchStartOrFinish($obj);
			addFightTime(null);
			if(!$obj.status)
			{
				setHideBtn();
				applyBtn.visible = true;
			}
			
		}
		
		
		
		/*比赛时间设置*/
		/**
		 * 检测时间 是否可以比赛
		 * 
		 */
		private function checkTimeIsSureMatch():void
		{
			var d :Date = AppData.getInstance().curDate;
			var arr:Array = AppData.getInstance().ladderDataManger.matchTimeList;
			var len:int = arr.length;
			var vo:MatchTimeVo;
			_isSureMatch = false;
			for(var i:int = 0;i < len;i++)
			{
				vo = arr[i];
				if(vo.starTime<=d.getHours()&& d.getHours() < vo.endTime )
				{
					_isSureMatch = true;
					break;
				}
			}
		}
		
		/**
		 *计算倒计时时间 
		 * 
		 */
		private function calculateTime():void
		{
			var d :Date = AppData.getInstance().curDate;
			var min:int = (d.getMinutes() % 1);
//			if(min < 9)
//			{
//				_time = 10 * 60 -((d.getMinutes() % 10) * 60 + d.getSeconds() + 1);
//			}else
//			{
//				_time = 11 * 60  - d.getSeconds()-1;
//			}
			_time = 10 * 60 -((d.getMinutes() % 10) * 60 + d.getSeconds()/* + 1*/);
//			trace(_time + "d.getSeconds()-- >" + d.getSeconds());
			updataTime();
			TimerManager.instance.addFunction(updataTime);
		}
		
		/**
		 *更新倒计时时间 
		 * 
		 */		
		private function updataTime():void
		{
			
			if(_time <= 0)
			{
				TimerManager.instance.removeFunction(updataTime);
				checkTimeIsSureMatch();
				if(_isSureMatch)
				{
					calculateTime();
				}else
				{
					time.text = "00:00";
					applyBtn.filters = [new ColorMatrixFilter([0.5,0.5,0.5,0,0,
						0.5,0.5,0.5,0,0,
						0.5,0.5,0.5,0,0,
						0,0,0,1,0,])];
				}
			}else
			{
				time.text = DateUtil.formatShowHMS(_time,false);
			}
			_time--;
		}
		
		/**
		 *设置隐藏按钮
		 * 
		 */
		private function setHideBtn():void
		{
			applyBtn.visible = false;
			cancelBtn.visible = false;
		}
		/**
		 *比赛状态  
		 * 1.自动报名
		 * 2.取消自动报名
		 * 3.手动报名
		 * 4.手动取消报名
		 * @param $obj
		 * 
		 */
		public function matchStatus($obj:Object):void
		{
			setHideBtn();
			switch($obj.type)
			{
				case 3:
					
					if(!$obj.status)
					{
						applyBtn.visible = true;
					}else
					{
						cancelBtn.visible = true;
					}
					break;
				case 4:
					
					if(!$obj.status)
					{
						cancelBtn.visible = true;
					}else
					{
						applyBtn.visible = true;
					}
					break;
			}
		}
		
		/**
		 *设置比赛数据 
		 * 
		 */
		private function setResultData():void
		{
			var len:int;
			var i:int ;
			len = resulctVec.length;
			for(i = 0;i < len;i++)
			{
				resulctVec[i].reset();
			}
			var arr:Array = AppData.getInstance().ladderDataManger.ladderInfovo.matchresuelList;
			len = arr.length > 10? resulctVec.length:arr.length;
			for(i = 0;i < len;i++)
			{
				resulctVec[i].setData(arr[i]);
			}
		}
		
		
		/**
		 *兑换 
		 * @param $obj
		 * 
		 */
		public function exchange($obj:Object):void
		{
			if(_exchangeview != null)
			{
				_exchangeview.show(AppData.getInstance().ladderDataManger.ladderInfovo.ladderintegral,AppData.getInstance().ladderDataManger.ladderInfovo.honour);
			}
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		override public function removeEvtListener():void
		{
			super.removeEvtListener();
			exchangeBtn.removeEventListener(MouseEvent.CLICK,onexchangeHandler);
			ruleBtn.removeEventListener(MouseEvent.CLICK,onruleHandler);
			moreBtn.removeEventListener(MouseEvent.CLICK,onMoreHandler);
			//			addFeelBtn.addEventListener(MouseEvent.CLICK,onAddFeelHandler);
			cancelBtn.removeEventListener(MouseEvent.CLICK,onCancelHandler);
			applyBtn.removeEventListener(MouseEvent.CLICK,onapplyHandler);
			battleBtn.removeEventListener(MouseEvent.CLICK,onBattleHandler);
			addBtn.removeEventListener(MouseEvent.CLICK,onAddFeelHandler);
		}
		override public function onCloseHandler(event:MouseEvent):void
		{
			this.dispatchEvent(new LadderEvent(ModuleEvent.REMOVE_MODULE));
		}
		override public function destroyView():void
		{
			TimerManager.instance.removeFunction(prepareupdataApplyList);
			removeEvtListener();
			if(_rankingview != null)
				_rankingview.destroyView();
			if(_exchangeview != null)
				_exchangeview.destroyView();
			_exchangeview = null;
			if(_ruleView != null)
				_ruleView.destroyView();
			_ruleView = null;
			
			while(_topListItem.length)
			{
				_topListItem.pop().destroyView();
			}
			while(_applyListItem.length)
			{
				_applyListItem.pop().destroyView();
			}
			_page.destroyView();
			_page = null;
			if(symbolSkin != null && symbolSkin.parent)
				symbolSkin.parent.removeChild(symbolSkin);
			super.destroyView();
		}
	}
}